<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<%
    String uuid = UUID.randomUUID().toString();
    request.setAttribute("uuid", uuid);
%>
   
    <div id="${uuid}_userExtTab">
    	<ul class="nav nav-tabs" role="tablist">
    		<li role="presentation" class="active">
    			<a href="#userInfoBox" role="tab" data-toggle="tab">
    			<span class="glyphicon glyphicon-user" aria-hidden="true"></span> 用户信息
    			</a>
    		</li>
    	</ul>
    	<div class="tab-content">
    		<div role="tabpanel" class="tab-pane fade in active"  id="userInfoBox">
		        <form  id="userForm" class="container-fluid am-margin-top">
		            <input type="hidden" name="id"/>
		            <input type="hidden" name="userType"/>
		            <input type="hidden" name="locked"/>
		            <input type="hidden" name="enabled"/>
		            
		            <div class="row">
		                <div class="form-group col-sm-6">
		                    <label for="loginName">登录名</label>
		                    <input type="text" name="loginName" class="form-control" readOnly="true">
		                </div>
		                <div class="form-group col-sm-6">
		                    <label for="password">密码</label>
		                    <input type="password" name="password" class="form-control" check-type="pwdStrength">
		                	<p class="help-block">不填写则表示不修改密码</p>
		                </div>
					</div>
					
					<div class="row">
		                <div class="form-group col-sm-6">
		                    <label for="userName">名称</label>
		                    <input type="text" name="userName" class="form-control" check-type="required">
		                </div>
		                <div class="form-group col-sm-6">
		                    <label for="mobileNo">手机号码</label>
		                    <input type="text" name="mobileNo"  class="form-control">
		                </div>
					</div>
					
					<div class="row">
		                <div class="form-group col-sm-6">
		                    <label for="idCardNo">证件号码</label>
		                    <input type="text" name="idCardNo" class="form-control" >
		                </div>
		                <div class="form-group col-sm-6">
		                </div>
	                </div>
	
	                <div class="form-group">
	                    <a href="javascript:void(0)" id="userSaveBt"  class="btn btn-primary">保存</a>
	                </div>
		        </form>
		    </div>
    	</div>
    </div>
<script type="text/javascript">
    $(function () {
        var uuid = '${uuid}';
        var id = '${param.id}';
        var userForm = $("#userForm");
        
        $('#userExtTab_'+uuid+' a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
        	$("#userRoleGrid_"+uuid).DataTable().table().columns.adjust();
        	$("#userOrgGrid_"+uuid).DataTable().table().columns.adjust();
        });
        
        var validform = userForm.validation();
        
        if (id) {
            $.getJSON(ctx + '/userAction/getUserById.do', {id: id}, function (data) {
                data.password = null;
                webUtils.fullForm({
                    form: $("#userForm"),
                    data: data
                });
            });
            
        }else{
        	$("#userInfoBox").removeClass("col-md-5");
        }
        
        function isValid(){
        	return validform.valid();
        }

        $("#userSaveBt").click(function () {
            if (!isValid()) {
                return false;
            }
            
            var datas=webUtils.formToObj(userForm);
            var postDataStr=JSON.stringify(datas);
			var postDataStrBase64=Base64.encode(postDataStr);
			$.post(ctx + '/userAction/savePersonalInfo.do',{
				code:postDataStrBase64
			},function(data){
				if (data.success) {
                    webUtils.alert("提交成功");
                    top.webUtils.topicPublish("user.edit.success", data);
                } else {
                	webUtils.error(data.msg);
                }
			},"json");
        });

    });
</script>